package com.pac.user.dao.impl;

import java.util.List;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.pac.user.bean.UserDetailBean;
import com.pac.user.dao.UserDetailDao;

/**
 * 添加用户详细信息
 * 
 * @author lujun.chen
 * @version [版本号, 2015年2月15日]
 * @see [相关类/方法]
 * @since [产品/模块版本]
 */
@Repository(value = "userDetailDao")
public class UserDetailDaoImpl implements UserDetailDao {

	@Autowired
	private SqlSessionTemplate sqlSessionTemplate;

	@Override
	public String addUserDetail(UserDetailBean userDetailBean) {
		sqlSessionTemplate.insert("addUserDetail", userDetailBean);
		return userDetailBean.getId();
	}

	@Override
	public boolean updateUserDetail(UserDetailBean userDetailBean) {
		int n = sqlSessionTemplate.update("updateUserDetail", userDetailBean);
		return n > 0;
	}

	@Override
	public boolean delUserDetail(UserDetailBean userDetailBean) {
		int n = sqlSessionTemplate.delete("delUserDetail", userDetailBean);
		return n > 0;
	}

	@Override
	public List<UserDetailBean> queryUserDetail(UserDetailBean userDetailBean) {
		return sqlSessionTemplate.selectList("queryUserDetail", userDetailBean);
	}

	@Override
	public int countUserDetail(UserDetailBean userDetailBean) {
		return sqlSessionTemplate.selectOne("countUserDetail", userDetailBean);
	}

}
